package bairui.international.console.web.controller.branch.branch.staff;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;
import com.querydsl.core.BooleanBuilder;

import bairui.international.model.domain.jpa.QTB_User;
import bairui.international.model.domain.jpa.TB_User;
import bairui.international.service.Service_User;

/**
 *
 * 详情
 *
 * @generated
 * 
 * @see STest_C_BranchCompanyStaff_Detail_CustomerPage 测试
 *
 */
@Controller
public class C_BranchCompanyStaff_Detail_CustomerPage
 extends SC_BranchCompanyStaff_Detail_CustomerPage 
{
	
	@Autowired private Service_User service_User;
	
	/**
	 * 客户列表
	 */
	@Action(CustomerPage.class)
	@GetMapping(value=CustomerPage.RequestMappingValue, consumes=MediaType.APPLICATION_JSON_VALUE)
	public @FomatOutput @ResponseBody Object customerPage(
		HttpServletRequest request, 
		@PathVariable(name=CustomerPage.PathVariableName.BranchId) long branchId, 
		@PathVariable(name=CustomerPage.PathVariableName.Id) long id
	) throws Exception {
		org.springframework.data.domain.Page<TB_User> page = service_User.page(
				it->filter(it, id, request), 
				CustomerPage.Output.page(request), 
				it->sort(it, request)
			);
		//
		return CustomerPage.Output.output(
				page
			);
	}
	
	/*
	 * 过滤
	 */
	static BooleanBuilder filter(QTB_User it, long id, HttpServletRequest request){
		return CustomerPage.Filter.query(it, request)
				.and(it.sender.id.eq(id));
	}
	
	/*
	 * 排序
	 */
	static Sort sort(QTB_User it, HttpServletRequest request){
		return CustomerPage.Output.sort(it, request);
	}
	
	

}
